import java.util.*;

public class GreatestCommonDivisorMethod {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        System.out.println("Skaitlis 1 : ");
        int n1 = scanner.nextInt();
        System.out.println("Skaitlis 2 : ");
        int n2 = scanner.nextInt();
        
        System.out.println("Lielākais dalītājs abiem skaitļiem - "
                + n1 + " un " + n2 + " ir " + gcd(n1, n2));
    }
    
    public static int gcd(int i, int k) {
        int gcd = 1;
        int j = 2;
        
        while(j <= i && j <= k) {
            if(i % j == 0 && k % j == 0)
                gcd = j;
            j++;
        }
        
        return gcd;
    }
}